package com.woniu.microchargeserver.common.mapper;

import com.woniu.microcommonsserver.entity.OwnerInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

/**物业微服务的mapper
 * @author: hejie
 * @date: 2021/2/2 6:00
 * @description:
 */
@Mapper
public interface PropertyMapper {

    /**
     * 根据 房间id，查询它的业主
     * @param sid 房间id
     * @return
     */
    @ResultType(OwnerInfoEntity.class)
    @Select("select o.id,o.name,o.phone " +
            "from owner_info as o,house_info as h where h.fk_user_id=o.id and h.fk_space_id=#{sid}")
    OwnerInfoEntity findOwerBySid(Long sid);

    /**
     * 根据 房间id，查询它的业主id
     * @param sid
     * @return
     */
    @ResultType(Long.class)
    @Select("select fk_user_id from house_info where fk_space_id=#{sid}")
    Long findOwerIdBySid(Long sid);

    /**
     * 根据 业主id，查询业主名字
     * @param id
     * @return
     */
    @ResultType(String.class)
    @Select("select name from owner_info where id=#{id}")
    String findOwerNameById(Long id);
}
